home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung 2 / Power-Programmierung CD 2 (Tewi)(1994).iso / c / library / mslang / svinst / svi_dist / assoc.c next >
Encoding:
C/C++ Source or Header  |  1993-11-15  |  2.0 KB  |  65 lines

  1. /*
  2.    Example AfterFile
  3.  
  4.    This is a program that sets up a Windows association between files with
  5.    the extension .SVI and the install build program SVI_BLD2.EXE. It also
  6.    shows how to get the dirve and root directory that the user installed
  7.    into. The drive is sent as command line parameter 1 and the directory
  8.    as parameter 2.
  9.  
  10.    It is intended as an example of the AfterFile function of SVInstal.
  11.  
  12.    Under the "Options" section of SVI_BLD2, you can specify a program to be
  13.    run at the end of the installation. This is just one example of what
  14.    might be done by the AfterFile.
  15.  
  16.    Rob Stevens
  17.    Soft Ventures
  18.    (403) 278-1681
  19.    CIS 71441,734
  20.  
  21.    NOTE, this is just an example an is not intended to be a complete treatment
  22.    of the subject of adding associations to Windows. You can edit the WIN.INI
  23.    file to see the association. Feel free to modify this code to meet your
  24.    requirements. If you prefer, Soft Ventures will write a custom AfterFile
  25.    for you for a small fee.
  26.  
  27. */
  28.  
  29. #include <windows.h>
  30. #include <stdio.h>
  31.  
  32. main(int _argc, char *_argv[])
  33. {
  34.   BOOL lSuccess;
  35.   char szWinEntry[] = "SVI_BLD2.EXE ^.svi";
  36.   char szMessage[80] = "The user installed into: ";
  37.  
  38.  
  39.   /* Build a string to display what drive and directory the user installed
  40.      into. You might use this information for renaming files after
  41.      installation.
  42.   */
  43.   strcat(szMessage, _argv[1]);  // the drive
  44.   strcat(szMessage, ", ");
  45.   strcat(szMessage, _argv[2]);  // the directory
  46.  
  47.   MessageBox(0, szMessage, "Sample Afterfile - assoc.exe", MB_OK||MB_ICONINFORMATION);
  48.  
  49.  
  50.  
  51.   /* This program puts an entry in WIN.INI, ".svi SVI_BLD2.EXE ^.svi" under
  52.      the [Extensions] section.
  53.   */
  54.  
  55.   lSuccess = WriteProfileString("Extensions", "svi", szWinEntry);
  56.  
  57.   if (lSuccess)
  58.       MessageBox(0, "Association added successfully",
  59.               "Afterfile updated WIN.INI", MB_OK);
  60.   else
  61.       MessageBox(0, "Association could not be added",
  62.               "Afterfile updated WIN.INI", MB_ICONSTOP);
  63. }
  64.  
  65.